package com.example.java_chatroom.utils;

import com.example.java_chatroom.model.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class GetUserInfoUtils {


    public static UserInfo getUserInfo(HttpServletRequest request) {
        HttpSession session;
        session = request.getSession(false);
        if (session == null) {
            //当前用户会话不存在 未登陆
            System.out.println("[getFriendList] 当前获取不到 Session 对象！");
            return null;
        }
        UserInfo userInfo = (UserInfo) session.getAttribute("userInfo");
        if (userInfo == null) {
            //当前用户对象没在会话中存在
            return null;
        }
        return userInfo;
    }
}
